package com.dxysun.spring.annotation;

import com.dxysun.spring.annotation.bean.MyBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.Scanner;

@ComponentScan("com.dxysun.spring.annotation")
@Configuration
public class AnnotationMain
{
    private static AnnotationConfigApplicationContext applicationContext;

    public static void main(String[] args)
    {

        applicationContext = new AnnotationConfigApplicationContext(AnnotationMain.class);
        Scanner in = new Scanner(System.in);

        while (in.hasNext())
        {
            String input = in.nextLine();
            MyBean myBean = applicationContext.getBean(MyBean.class);
           /* try {
                myBean.hello(input);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }*/
            new Thread(() -> {
//                MyBean myBean = applicationContext.getBean(MyBean.class);
                try {
                    myBean.hello(input);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }

    }
}
